package br.com.perkins.myproject.service;

import javax.annotation.Resource;

import br.com.perkins.myproject.service.exception.ServiceException;

public class ServiceImpl {
	@Resource
	private ServiceException serviceException;
	private boolean newErrorSession = true;

	protected void newServiceException(Integer exceptionNumber) {
		if (newErrorSession) {
			serviceException.newErrorSession();
			newErrorSession = false;
		}
		serviceException.setServiceException(exceptionNumber);
	}

	protected void checkForServiceException() {
		if ((serviceException == null) || (serviceException.getServiceExceptions().size() == 0)) {
			return;
		} else {
			newErrorSession = true;
			throw serviceException;
		}
	}

}